home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGBLER / ASMCODE2.LZH / PX.DOC < prev    next >
Text File  |  1984-05-02  |  17KB  |  382 lines

  1.                             PX Procedure Cross Referencer
  2.                              User's Guide for Ver. 1.00
  3.                                    April 27, 1984
  4.  
  5.           PURPOSE
  6.  
  7.           In the process of writing large assembler programs, it sometimes
  8.           becomes difficult to keep track of where procedures (subroutines)
  9.           are located and of where they are referenced (called).  Typically,
  10.           the programmer will include a prologue for each procedure, listing
  11.           the procedures it calls and the procedures from which it is
  12.           called.  Unfortunately, this practice requires the programmer
  13.           to update the procedure prologue every time a new call to it
  14.           is added; this can get pretty tedious for a large program, and
  15.           (also typically) the programmer's good intentions fall by the
  16.           wayside as the program gets larger.
  17.  
  18.           PX is a procedure documenter.  It allows you to print out all
  19.           of the procedure prologues in a "dictionary" and to then print
  20.           a cross reference of all procedural calls;  i.e., a listing
  21.           of which procs call which procs.  It just makes life a little
  22.           easier.
  23.  
  24.  
  25.           WHAT YOU NEED
  26.  
  27.           You need one or more disk drives, at least 128K of memory, and
  28.           DOS 2.00 or later.  A printer would be nice, but it's not a
  29.           requirement.  PX is designed to understand files written for
  30.           the Microsoft Assembler: IBM's ASM or MASM, or Microsoft Version
  31.           1.25.  With some restrictions, PX will also work with files
  32.           written for Digital Research's RASM-86.
  33.  
  34.  
  35.           OUTPUT FORMAT
  36.  
  37.           PX's output (which can be sent to disk, screen, printer, or
  38.           any other device) is in two parts.  The first part is the procedure
  39.           dictionary; it is simply the text of your procedure prologues,
  40.           preceded by the name of the procedure and the file/line where
  41.           the prologue was found.  The dictionary looks like this:
  42.  
  43.             PX 1.00 Procedure Dictionary           Date  Time  Page 1
  44.  
  45.             MYPROC [File THISFILE.ASM at 50]
  46.             ; This is the procedure prologue for MyProc...
  47.             ; It contains whatever you put in it
  48.  
  49.             VERYSLICK [File THISFILE.ASM at 70]
  50.             ; And this is the prologue for proc VerySlick...
  51.             ; And so on...
  52.  
  53.  
  54.                                                                           2
  55.                               ==== PX User's Guide ===
  56.  
  57.           The second part is the procedure cross reference.  It is formatted
  58.           like this:
  59.  
  60.             PX 1.00 Procedure Cross Reference      Date  Time  Page x
  61.  
  62.             Proc MYPROC                 Near in THISFILE.ASM at 56 [1]
  63.             DUMB_PROC GREAT_PROC PROC1 PROC2 VERYSLICK
  64.  
  65.             Proc VERYSLICK              Far  in THISFILE.ASM at 75 [1]
  66.             PROC6
  67.  
  68.           The first line of each entry names the procedure, and specifies
  69.           its near/far attribute and the file and line where it was found.
  70.           The number in brackets is the dictionary page where the procedure's
  71.           prologue is printed.  The second and subsequent lines of each
  72.           procedure entry comprise an alphabetical list of procedures
  73.           which contain calls to the named proc.  For example, procedure
  74.           MYPROC is called by DUMB_PROC, GREAT_PROC, PROC1, PROC2, and
  75.           VERYSLICK.
  76.  
  77.           Note that the line numbers in the dictionary and cross reference
  78.           sections may differ.  In the dictionary, the line number is
  79.           the line where the prologue was found; in the cross reference,
  80.           it is the line where the PROC statement was found.
  81.  
  82.           At the end of each report, PX will print a line like:
  83.  
  84.                UnDef: 2   UnRef: 6   Use Factor: 12.1%
  85.  
  86.           This indicates that PX found calls to 2 procedures that it knew
  87.           nothing about (Undefined), and 6 procedures were defined but
  88.           unreferenced (nobody CALLed them [uncalled for procedures?]). PX
  89.           used about 12.1% of its available table space.
  90.  
  91.  
  92.           INCLUDE FILES
  93.  
  94.           PX processes include files as it encounters them in the source
  95.           files.  However, it will read a given include file only once.
  96.           For example, if you are processing multiple source files, and
  97.           they each INCLUDE the file "MACLIB.ASM", PX will read MACLIB
  98.           only the first time.
  99.  
  100.  
  101.           DEFINING PROCEDURE PROLOGUES
  102.  
  103.           If PX is to be able to print a "dictionary" of procedure prologues,
  104.           it must be able to find the prologues in the source code.  For
  105.           this purpose, PX understands two keywords in your file:  "DICT"
  106.           and "ENDD". You need to bracket your prologues with this pair
  107.           (in comments of course):
  108.  
  109.  
  110.                                                                           3
  111.                               ==== PX User's Guide ===
  112.  
  113.                ;Dict MyProc
  114.  
  115.                ; --------------------------
  116.                ; Procedure MyProc
  117.                ; Entry conditions:
  118.                ;   ...
  119.                ; Exit conditions:
  120.                ;   ...
  121.                ; --------------------------
  122.                ;EndD
  123.                MyProc proc near
  124.                ...
  125.  
  126.           When PX reads the file containing the above "code", it will
  127.           print out everything between "Dict MyProc" and "EndD".  It doesn't
  128.           make any difference how you capitalize the two keywords, but
  129.           they MUST begin in the first column after the semicolon.  That
  130.           is, this won't work:
  131.  
  132.                ;  dict myproc
  133.  
  134.           The procedure name must follow the DICT keyword;  this enables
  135.           PX to match up procedure CALLs with the dictionary page where
  136.           the prologue appears.
  137.  
  138.  
  139.           RUNNING PX
  140.  
  141.           The basic syntax for invoking PX is as follows:
  142.  
  143.                PX {infile} {/command}
  144.  
  145.           The infile(s) specify which assembler source files you want
  146.           PX to read.  For example,
  147.  
  148.                PX thisfile thatfile
  149.  
  150.           would read the files "thisfile" and "thatfile", prepare a procedure
  151.           dictionary and cross reference (hereinafter Xref), and display
  152.           the results.  If PX cannot find a file called "thisfile" it
  153.           will search for "thisfile.asm" before it gives up.  You can
  154.           specify up to twenty parameters (input files and commands) on
  155.           one command line.
  156.  
  157.           The commands are as follows:
  158.  
  159.                /o=filename    Specifies an output file
  160.                /i=filename    Specifies a command file
  161.                /s=filename    Specifies a "skip" file
  162.                /p=nn:nn       Set output page length:width
  163.                /x             Prepare Xref only
  164.                /d             Prepare dictionary only
  165.  
  166.   
  167.                                                                           4
  168.                               ==== PX User's Guide ===
  169.  
  170.           The commands are entered on the DOS command line and are always
  171.           preceded by a slash (/); PX assumes that anything without a
  172.           slash is an assembler source file to be processed.  Here is
  173.           an example of a command line with options:
  174.  
  175.                PX thisfile thatfile /x /p=66:132 /o=prn
  176.  
  177.           This PX run will process the files "thisfile" and "thatfile";
  178.           it will produce only an Xref (no dictionary); it will format
  179.           output for pages with 66 lines of 132 characters each; and the
  180.           output will go to the system printer.  We'll now cover each
  181.           of the commands in turn.  (Commands and files may be specified
  182.           on the command line in any order, by the way.)
  183.  
  184.  
  185.           OUTPUT FILE SELECTION (/O)
  186.  
  187.           The /o command tells PX where to send its report.  Any valid
  188.           device that is defined for output to DOS is OK:
  189.  
  190.                /o=prn    /o=lpt1   /o=com1   /o=con    /o=nul
  191.  
  192.           You may also send output to a file:
  193.  
  194.                /o=a:zapdict.txt    /o=crossref
  195.  
  196.           Due to a compiler restriction, path names cannot currently be
  197.           used in ANY file specifications (input, output, or command).
  198.  
  199.           Output defaults to console if no /o command is given.
  200.  
  201.  
  202.           COMMAND FILE SELECTION (/I)
  203.  
  204.           PX command lines can be quite long if they contain multiple
  205.           source files and options; it is quite easy to exceed the maximum
  206.           length of a DOS command line (about 160 or so characters).
  207.           It would also be nice to avoid repetitive typing if you are
  208.           going to be using PX a number of times on the same assembler
  209.           project.  Fortunately, PX can obtain its commands from a standard
  210.           DOS text file known as a command file.
  211.  
  212.           The /i command tells PX to look in a text file for further commands.
  213.           For example, the command "/i=zap.px" tells the program to look
  214.           for additional commands in a file called "zap.px".  (The format
  215.           of command files is detailed later.) If there is no extension
  216.           on the specified command file name and PX cannot find a file
  217.           with that name, it will append ".px" and try again.  For example,
  218.           "/i=zap" would find the file "zap.px" if "zap" did not exist.
  219.  
  220.           The "i" in "/i", by the way, stands for "input commands".  The
  221.           more logical "/c" is reserved for a future command.
  222.    
  223.                                                                           5
  224.                               ==== PX User's Guide ===
  225.  
  226.  
  227.  
  228.           SKIP FILES (/S)
  229.  
  230.           PX is interested only in procedures, their prologues, and their
  231.           calls.  It is not interested in macros, data definitions, or
  232.           long files full of equates.  If such files are INCLUDEd in your
  233.           source, you can instruct PX to ignore them with a /s command.
  234.           For example, the command "/s=equates.asm" tells PX to ignore
  235.           the statement "include equates.asm" in the source.  This can
  236.           save you considerable processing time in large projects.
  237.  
  238.  
  239.           PAGE SPECS (/P)
  240.  
  241.           You can specify the length and width of the output medium with
  242.           the /p option.  The format is
  243.  
  244.                /p=length:width
  245.  
  246.           Either parameter may be missing. Examples:
  247.  
  248.                /p=66:132      Set length=66 lines, width=132 cols
  249.                /p=:40         Set width=40
  250.                /p=120         Set length=120
  251.  
  252.           PX defaults to a page of length 66 and width 80.  It skips about
  253.           6 lines at the end of each page.  Limits: 20 <= length <= 200;
  254.           40 <= width <= 240.
  255.  
  256.  
  257.           XREF/DICT ONLY (/X and /D)
  258.  
  259.           In some cases you may wish to skip either the dictionary or
  260.           the Xref portion of the report.  A "/x" command tells PX to
  261.           print ONLY the Xref; "/d" prints ONLY the dictionary.  Specifying
  262.           BOTH /x and /d is silly, and PX will tell you so.
  263.  
  264.  
  265.           COMMAND FILE FORMAT
  266.  
  267.           Command files are simply DOS text files containing lists of
  268.           PX commands and input files.  You can put as many files/commands
  269.           as you want on each line, separated by commas, space, or tabs.
  270.           The semicolon specifies a comment, just as in MASM; anything
  271.           after a semicolon will be ignored.  Here is an example of a
  272.           command file:
  273.  
  274.  
  275.                                                                           6
  276.                               ==== PX User's Guide ===
  277.  
  278.                ; ----- PX command file for ZAP program
  279.                /p=66:132                     ; Pagesize = 66x132
  280.                zap, edit, display, diskio    ; Input files
  281.                /s=equates, /s=maclib.mac     ; Skip file
  282.                /o=zap.ref                    ; Output to "zap.ref"
  283.  
  284.           There is one restriction on command files: they cannot be nested.
  285.           That is, a command file cannot contain a "/i" command.
  286.  
  287.           When PX has completed processing a command file, it returns
  288.           to the command line if there are more parameters.  For example,
  289.  
  290.                PX  /x  /i=cmdfile.px  /i=cmdfile2.px  /s=xtrafile
  291.  
  292.           is perfectly OK.
  293.  
  294.  
  295.           QUICK PRINCIPLES OF OPERATION
  296.  
  297.           PX works by scanning for two assembler reserved words: PROC
  298.           and CALL.  When it encounters a PROC statement, it sets up a
  299.           table entry for the named procedure; when it encounters a CALL
  300.           statement, it looks for the CALLed label in the procedure table.
  301.           If no entry is found, a new entry is created and PX waits for
  302.           a later definition.
  303.  
  304.           A few situations will cause problems for PX:
  305.  
  306.                o Table-driven calls.  If you set up a table of routines
  307.                     to be called and execute the call via CALL [BX] or
  308.                     some such, PX can't know what's being called.  The
  309.                     call is ignored.
  310.  
  311.                o Calls to labels not defined via PROC statements (e.g.,
  312.                     CALL LABEL, where LABEL is defined "LABEL:" rather
  313.                     than "LABEL PROC NEAR").  PX creates a table entry
  314.                     for the label, but cannot find a definition.  This
  315.                     results in an undefined procedure.
  316.  
  317.                o Jumps to procedures. If a procedure is JuMPed to rather
  318.                     than CALLed, PX will not find the reference.
  319.  
  320.           Note, however, that PX will create a table entry when it encounters
  321.           a ";DICT procname" directive.  You may be able to use this to
  322.           overcome the second problem above.  (This also allows you to
  323.           use PX with RASM-86, which has no PROC statement or equivalent.)
  324.           When a table entry is defined only by a DICT directive, PX will
  325.           not know whether it is NEAR or FAR.
  326.  
  327.  
  328.                                                                           7
  329.                               ==== PX User's Guide ===
  330.  
  331.           LIMITS, RESTRICTIONS, AND QUIRKS
  332.  
  333.           On a 128K machine, PX has about 63K available for storage of
  334.           the procedure and reference tables.  This is plenty for all
  335.           but the largest projects.  For example, I have used PX on a
  336.           program consisting of 16 files totaling more than 110K of source;
  337.           only about 11% of the available memory was used.  PX is compiled
  338.           using the small memory model (for execution speed), so larger
  339.           amounts of RAM do not increase the available storage.
  340.  
  341.           PX allows for a maximum of 40 files of any type that it keeps
  342.           track of: source files, include files, and skip files.
  343.  
  344.           Regrettably, PX does not, at this point, understand the COMMENT
  345.           directive in assembler source.  It will scan anything between
  346.           COMMENT delimiters; if the keywords PROC or CALL appear in the
  347.           comments, you may find some strange results in the cross refer-
  348.           ence. (PROCs or CALLs in procedure prologues are OK.)
  349.  
  350.           The current version of the C compiler used does not permit path
  351.           names in file specifications.  This should be corrected shortly.
  352.  
  353.           Due to a compiler oddity, commas cannot be used as command line
  354.           parameter separators; use spaces or tabs.  Commas are OK in
  355.           command files, however.
  356.  
  357.  
  358.                        ---------------------------------------
  359.  
  360.                                    The PX program
  361.                                 and this document are
  362.                                 Copyright (C) 1984 by
  363.  
  364.                                Christopher J. Dunford
  365.                               10057-2 Windstream Drive
  366.                               Columbia, Maryland 21044
  367.  
  368.           -- who hereby authorizes you to use PX for your own private,
  369.           noncommercial use.  You may copy PX for others, but you may
  370.           not charge for the copies or for the use of the program or for
  371.           anything else connected with the PX program, in any manner,
  372.           whatsoever.  Please do not alter or bypass the notice displayed
  373.           at program startup.  You will find it to be unobtrusive and
  374.           in good taste.
  375.  
  376.           -- and who welcomes your comments, criticisms, suggestions,
  377.           or bug reports (provided they are also unobtrusive and in good
  378.           taste), directed to the above address or to CompuServe 71076,1115.
  379.           He will also accept phone calls, as long as West Coast people
  380.           exercise restraint and recognize that 11PM PST is not a good
  381.           time to call the East Coast.
  382.